<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="安装" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doShow(id){
		showWin(1024,600,'/business/BusinessBillInfo.ihtm?id='+id);
	}
	function doSetu(id){
		var url="/business/SetuBillNew.ihtm?bb_id="+id;
		ShowIframe("安装",url,1024,500,"doSetuCallBack("+id+")");
	}
	function doSetuCallBack(id){
		if(popRetVal!=null){
			var url=getProgramLocation()+"&current_page=${qr.pageIndex}";
			ShowConfirm('确认框','现在打印安装单？',340,80,"doSetuCallBackPriExt('"+url+"',"+popRetVal+")");
		}else{
			document.getElementById("search_key").select();
		}
	}
	function doSetuCallBackPriExt(url,id){
		if(popRetVal!=null){
			window.location=url+"&print_id="+id;
		}else{
			window.location=url;
		}
	}
	function getProgramLocation(){
		var searchKey=encodeURIComponent("${searchKey}");
		return "/business/BusinessBillListForSetu.ihtm?search_key="+searchKey+"&type=${type}&ts_id=${tsId}";
	}
	function doSearch(){
		var type=document.getElementById("type").value;
		var tsId=document.getElementById("ts_id").value;
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		window.location="/business/BusinessBillListForSetu.ihtm?search_key="+searchKey+"&type="+type+"&ts_id="+tsId+"&need_pop=Y";//点查询时才需要自动弹窗
	}
	function doGo(pageIndex){
		window.location=getProgramLocation()+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doSetu(str);
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		//Window_Onload();
		document.getElementById("search_key").select();
		if(window.screen.availWidth>1024){
			var w=window.screen.availWidth*0.98;
			window.resizeTo(w,600);
			document.getElementById("mainDiv").style.width=(w-60)+"px";
			//居中
			var resizeWinTop=(window.screen.availHeight-600)/2;
			var resizeWinLeft=(window.screen.availWidth-w)/2;
			window.moveTo(resizeWinLeft,resizeWinTop);
		}
		
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location=getProgramLocation()+"&current_page=${qr.pageIndex}";//有print_id,need_pop这些参数,所以这里不能直接refresh
		}
	}
	function doPrintCallBack(){
		var printId="${printId}";
		if(printId!=null && printId!=""){
			showWin(900,600,"/business/SetuBillPrint.ihtm?id="+printId);
		}else{
			<c:if test="${qr.totalCount==1 && needPop=='Y'}">
			doSetu(${qr.list[0][0]});
			</c:if>
		}
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();doPrintCallBack();" class="sheet">
<div class="sheet-main" style="width:980px" id="mainDiv">
  <div class="sheet-top">
    <div class="content">
      <h2>工程安装</h2>
      <p>根据业务单的完工状态、安装状态进行分类查询，生成安装单。<span style="color:blue">蓝色</span>表示业务单已开过安装单</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="100%" id="searchTbl">
          <tbody>
            <tr>
              <td align="right">
				  <select name='ts_id' id="ts_id">
					<option value="0">==请选择账套==</option>
					<c:forEach var="item" items="${tsList}">
					<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option>
					</c:forEach>
		  		  </select>
				  <select name="type" id="type">
				  	<option value="">==全部==</option>
					<option value="COMP" <c:if test="${type=='COMP'}">selected</c:if>>完工未安装</option>
				  </select>
				  <input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" style="width:80px" value="${searchKey}" title="以客户名称、客户拼音字头、摘要、业务单号、电话进行模糊查询">
				  <input type="button" class="buttom search-but" value=" 查 询" onClick="doSearch();" title="以客户名称、客户拼音字头、摘要、业务单号、电话进行模糊查询">
			  </td>
            </tr>    
           </tbody>      
        </table>
      </div>
	  <%@include file="../inc/AlertMsg.jsp"%>
      <div class="table-list">
        <table width="100%">      
			<tr >
				<th  width="12%">单号</th>
				<th  width="8%">订货日期</th>
				<th  width="20%">订货单位</th>
				<th  width="22%">摘要</th>
				<th  width="8%">交货日期</th>
				<th  width="22%">安装要求</th>
				<th  width="8%">操作</th>
			</tr>
			<c:forEach var="item" items="${qr.list}" varStatus="i">
				<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
				<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
				<c:set var="defaultFontColor" value="black" />
				<c:if test="${item[7]=='Y'}"><c:set var="defaultFontColor" value="blue" /></c:if>
				<tr class="${trClass}" index="${i.index+1}" style="color:${defaultFontColor};cursor:pointer;" defaultFontColor="${defaultFontColor}" ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
					<td>
						<input type="radio" name='query_checkbox' value="${item[0]}" style="display:none">
						${item[1]}
					</td>
					<td><fmt:formatDate value="${item[2]}" pattern="yyyy-MM-dd"/></td>
					<td>${item[3]}</td>
					<td>${item[4]}</td>
					<td>
						<c:if test="${item[5]!=null}">
						<fmt:formatDate value="${item[5]}" pattern="yyyy-MM-dd HH:mm"/>
						</c:if>
					</td>
					<td>${item[6]}</td>
					<td>
						<a href="javascript:doShow('${item[0]}');">查看</a>
						<a href="javascript:doSetu('${item[0]}');">开安装单</a>
					</td>
				</tr>
			</c:forEach>
		</table>
		<%@include file="../inc/Pages.jsp"%>
      </div>     
    </div>
  </div>
</div>
</body>
</html>

